// Compute i,k of variable matrix product

int var_prod_ele(long n, int A[n][n], int B[n][n], long i, long k) {
  long j;
  int result = 0;
  for (j = 0; j < n; j++)
    result += A[i][j] * B[j][k];

  return result;
}

// Compute i,k of variable matrix product
int var_prod_ele_opt2(long n, int A[n][n], int B[n][n], long i, long k) {
  int *Arow = A[i];
  int *Bptr = &B[0][k];
  int result = 0;
  long j;
  for (j = 0; j < n; j++) {
    result += Arow[j] * *Bptr;
    Bptr += n;
  }
  return result;
}

/*
gcc -O1 -S s8.var_prod_ele.c
*/